package com.leonardo.lengthexample;

import com.leonardo.beanme.fields.InputField;
import com.leonardo.beanme.metadatahandlers.tags.InnerFieldTagHandler;
import com.leonardo.beanme.model.BeanForm;

public class MaxLengthTagHandler extends InnerFieldTagHandler {

	public String getTagName() {
		return "maxlength";
	}
	
	public void handle(InputField field, BeanForm form) {
		if(field instanceof InputWithLength) {
			InputWithLength withLength = (InputWithLength) field;
			int maxlength = Integer.valueOf(getInnerText()).intValue();
			form.addListener(new LengthHandler(withLength, maxlength));
		} else
			System.out.println("length tag will be desconsidered");
	}

}
